<template>
  <div class="navBar">
    <div class="arrow_box">
      <van-icon
        name="arrow-left"
        class="arrow"
        @click="back"
        v-show="leftArrow"
      />
    </div>
    <div class="title_box">
      <div class="title">{{ title }}</div>
    </div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'
import { ref } from 'vue'
export default {
  props: {
    title: {
      type: String,
      default: '',
    },
    arrow: {
      type: Boolean,
      default: false,
    },
  },
  setup(props) {
    let router = useRouter()
    let navTitle = ref(props.title)
    let leftArrow = ref(props.arrow)
    let back = () => {
      router.go(-1)
    }
    return {
      navTitle,
      back,
      leftArrow,
    }
  },
}
</script>

<style lang="less" scoped>
.navBar {
  height: 40px;
  background: #ffffff;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: #333333;
  line-height: 40px;
  display: flex;
  align-items: center;
  box-shadow: 0px 3px 15px 0px rgba(0, 122, 253, 0.1);
  .arrow_box {
    width: 30px;
    margin-left: 15px;
  }
  .title_box {
    padding-left: 95px;
    width: 80px;
    text-align: center;
  }
}
</style>
